package com.dao.impl;

import com.dao.MeetingRecordDao;
import com.domain.MeetingRecord;
import com.factory.OfficeFactory;

import java.util.ArrayList;

public class MeetingRecordDaoImol implements MeetingRecordDao {


    @Override
    public boolean save(MeetingRecord meeting) {
        String sql = "insert into meeting_record values(null,?,?,?,?)";

        return OfficeFactory.update(sql,meeting.getM_time(),meeting.getM_participants(),meeting.getM_recorder(),
                meeting.getM_content());
    }

    @Override
    public boolean delete(int id) {
        String sql = "delete from meeting_record where id = ?";

        return OfficeFactory.update(sql,id);
    }

    @Override
    public ArrayList<MeetingRecord> select() {
        String sql = "select * from meeting_record";

        return OfficeFactory.select(new MeetingRecord(),sql);
    }

    @Override
    public boolean update(MeetingRecord meeting) {
        String sql = "UPDATE meeting_record SET m_time = ? , m_participants = ? , m_recorder = ?" +
                " , m_content = ? where id = ?";

        return OfficeFactory.update(sql,meeting.getM_time(),meeting.getM_participants(),meeting
                .getM_recorder(),meeting.getM_content(),meeting.getId());
    }
}
